import React from 'react';
import { Button } from 'antd';
import DemoStore from '../stores/DemoStore';
import CrmLogDetailDialog from '../components/dialog/CrmLogDetailDialog';

class Main extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      weaCrmLoaded: false,
      visible: false,
      demoStore: new DemoStore(),
    };
  }

  showDialog = (bl) => {
    this.setState({ visible: bl });
    this.state.demoStore.setDetailVisible(bl);
    this.state.demoStore.setDetailTitle('日志修改详细');
    this.state.demoStore.updateDetailkey(`${new Date().getTime()}`);
    const record = {};
    record.randomFieldId = 1;
    record.newValues = '{"modifytime":"09:34:35","ldapuser":"test11111"}';
    record.oldValues = '{"modifytime":"09:33:55","ldapuser":"test"}';
    record.params = '{"passingCert":"0","isPush":"1","request_header_user_agent":"Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.132 Safari/537.36 Edg/80.0.361.66","ldapType":"AD","param_ip":"127.0.0.1","ldapUserForView":"test11111","factoryClass":"com.sun.jndi.ldap.LdapCtxFactory","ldapName":"测试1","isAuth":"0","ldapPassword":"EB00349D184181958D26C8B3997FCE4C","protocol":"ldap","modifyTime":"","ldapUser":"www.dcm.com.cn\\test11111","baseDomain":"www.dcm.com.cn","ldapId":"ceshi1","class":"class com.api.integration.ldap.bean.LdapBaseBean","createDate":"","keystorePassword":"","modifyDate":"","ip":"192.168.29.160","isPull":"1","isAdAccount":"0","isencryptPWD":"0","isUsed":"0","keystorePath":"","ldapPasswordEncrypt":"EB00349D184181958D26C8B3997FCE4C","createTime":"","port":"389","isSSO":"0"}';
    this.state.demoStore.setDetailRecord(record);
  }

  render() {
    const { visible, demoStore } = this.state;
    return (
      <div style={{ height: '100%' }}>
        <Button ecId={`${this && this.props && this.props.ecId || ''}_Button@pi8xdc`} type="primary" onClick={() => this.showDialog(true)}>Primary</Button>
        {visible && <CrmLogDetailDialog ecId={`${this && this.props && this.props.ecId || ''}_CrmLogDetailDialog@3ob837`} logStore={demoStore} />}
      </div>
    );
  }
}
export default Main;
